/* 003.c */


.LC0:
	.string "please input a number string:\n"
	
.LC1:
	.string "please input n(2 or 8 or 16):\n"
	
.LC2:
	.string "%d"
	
.LC3:
	.string "data error!!"
	
.LC4:
	.string "the decimal is %ld\n"

.globl _main

_main:
	pushl %ebp
	movl %esp,%ebp
	subl $0x1000,%esp
	
	movl $0,-0x1000(%ebp) /* t1 */
	movl $0,-0xffc(%ebp) /* i */
	movl $0,-0xff8(%ebp) /* n */
	movl $0,-0xff4(%ebp) /* t */
	movl $0,-0xff0(%ebp) /* t3 */
	movl $0,-0xfe0(%ebp) /* a */
		
	pushl $.LC0 
	movl $0,%eax 
	call _printf 

	leal -0xfe0(%ebp),%edi /* a */
	pushl %edi 
	call _gets 
	
	leal -0xfe0(%ebp),%edi /* a */
	pushl %edi 
	call _strupr 
	
	leal -0xfe0(%ebp),%edi /* a */
	pushl %edi 
	call _strlen
	movl %eax,-0xff0(%ebp) /* t3 */
	
	movl $0,-0x1000(%ebp) /* t1 */
	
	pushl $.LC1
	call _printf 
	
	leal -0xff8(%ebp),%edi /* n */
	pushl %edi 
	pushl $.LC2 
	movl $0,%eax 
	call _scanf 
	
	movl $0,-0xffc(%ebp) /* i */
	jmp .Lmain_400
.Lmain_500:
	movl -0xffc(%ebp),%eax /* i */	
	leal -0xfe0(%ebp),%edi /* a */
	movb 0(%edi,%eax,1),%al /* a[i] */
	subb $('0'),%al
	movsbl %al,%eax 
	cmpl -0xff8(%ebp),%eax /* n */
	jl .Lmain_490
	
	movl -0xffc(%ebp),%eax /* i */	
	leal -0xfe0(%ebp),%edi /* a */
	movb 0(%edi,%eax,1),%al /* a[i] */
	cmpb $('A'),%al
	jge .Lmain_490
	jmp .Lmain_488  
	
.Lmain_490:
	movl -0xffc(%ebp),%eax /* i */	
	leal -0xfe0(%ebp),%edi /* a */
	movb 0(%edi,%eax,1),%al /* a[i] */
	
	movb $('A'),%cl
	subb %cl,%al
	movsbl %al,%eax
	addl $10,%eax
	cmpl -0xff8(%ebp),%eax /* n */
	jl .Lmain_485

.Lmain_488:
	pushl $.LC3
	call _printf
	
	pushl $0
	call _exit 
	
.Lmain_485:
	movl -0xffc(%ebp),%eax /* i */	
	leal -0xfe0(%ebp),%edi /* a */
	movb 0(%edi,%eax,1),%al /* a[i] */
	
	cmpb $('0'),%al 
	jl .Lmain_480
	
	cmpb $('9'),%al
	jg .Lmain_480
	
	movl -0xffc(%ebp),%eax /* i */	
	leal -0xfe0(%ebp),%edi /* a */
	movb 0(%edi,%eax,1),%al /* a[i] */
	subb $('0'),%al
	movb %al,-0xff4(%ebp) /* t */
		
	jmp .Lmain_470 
	
.Lmain_480:
	cmpl $11,-0xff8(%ebp) /* n */
	jl .Lmain_470
	
	movl -0xffc(%ebp),%eax /* i */	
	leal -0xfe0(%ebp),%edi /* a */
	movb 0(%edi,%eax,1),%al /* a[i] */
	
	cmpb $('A'),%al
	jl .Lmain_470
	
	movl -0xffc(%ebp),%eax /* i */	
	leal -0xfe0(%ebp),%edi /* a */
	movb 0(%edi,%eax,1),%cl /* a[i] */
	movsbl %cl,%ecx 
	
	movb $('A'),%al
	movsbl %al,%eax
	addl -0xff8(%ebp),%eax /* n */
	subl $10,%eax 
	cmpl %ecx,%eax 
	jl .Lmain_470 
	
	movl -0xffc(%ebp),%eax /* i */	
	leal -0xfe0(%ebp),%edi /* a */
	movb 0(%edi,%eax,1),%cl /* a[i] */
	
	subb $('A'),%cl 
	movsbl %cl,%ecx
	addl $10,%ecx 
	movl %ecx,-0xff4(%ebp) /* t */
	
.Lmain_470:
	movl -0x1000(%ebp),%eax /* t1 */
	imull -0xff8(%ebp),%eax /* n */
	addl -0xff4(%ebp),%eax /* t */
	movl %eax,-0x1000(%ebp) /* t1 */
		
	addl $1,-0xffc(%ebp) /* i */
		
.Lmain_400:
	movl -0xffc(%ebp),%eax /* i */
	cmpl -0xff0(%ebp),%eax /* t3 */
	jl .Lmain_500
	
	movl -0x1000(%ebp),%eax /* t1 */
	pushl %eax 
	pushl $.LC4
	movl $0,%eax 
	call _printf 
	
	movl $0,%eax
	leave
	ret
	